package com.web.utils;

import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

/**
 * Created by FDjavaone on 2018/7/19.
 */
public class MapTestUtil {
    /**
     * 递归删除map中的null值
     *
     * @param map
     * @return
     */
    @SuppressWarnings({"unchecked", "rawtypes"})
    public static Map<String, String> mapRemoveWithNullByRecursion(Map<String, String> map) {
        Set<Map.Entry<String, String>> set = map.entrySet();
        Iterator<Map.Entry<String, String>> it = set.iterator();
        while (it.hasNext()) {
            Map.Entry<String, String> en = it.next();
            if (null == en.getValue() || "".equals(en.getValue())) {
                it.remove();
            }
        }
        return map;
    }
}
